package com.java.star.mall.front.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.java.star.mall.common.response.JsonResult;
import com.java.star.mall.front.pojo.param.AdvancedOrderParam;
import com.java.star.mall.front.service.WechatPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 微信支付Controller
 */
@Api(value = "pay", tags = "微信支付")
@RestController
@RequestMapping("/pay")
@Validated
public class WechatPayController {

    @Autowired
    WechatPayService wechatPayService;

    @ApiOperation(value = "生成微信支付预付单")
    @ApiOperationSupport(order = 100)
    @PostMapping("/generateAdvancedOrder")
    public JsonResult<Void> generateAdvancedOrder(@Valid @RequestBody AdvancedOrderParam advancedOrderParam) {
        wechatPayService.generateAdvancedOrder(advancedOrderParam);
        return JsonResult.ok();
    }
}
